package salercomputer;

import salercomputer.CPU.CPU;
import salercomputer.Disk.Disk;
import salercomputer.model.Component;
import salercomputer.myInterface.Workable;

public class Computer extends Component implements Workable {

    private CPU cpu;
    private Disk disk;

    public Computer(CPU cpu, Disk disk,String name) {
        super(name,-1.0);
        this.cpu = cpu;
        this.disk = disk;
        super.setPrice(cpu.getPrice()+disk.getPrice());
    }

    @Override
    public void work() {
        cpu.work();
        disk.work();
    }

    @Override
    public String description(){
        StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.append(super.description())
                .append("CPU description")
                .append(cpu.description())
                .append("}")
                .append(";Disk description:{")
                .append(disk.description())
                .append("}");
        return stringBuilder.toString();
    }
}
